<?php
ob_start();
include_once "../connect.php";
session_start();
$id_member = $_SESSION["id_member"];

$rst_id = $_POST["rst_id"];
$radResult = $_POST["radResult"];
$rstDetail = $_POST["txtResult"];
$alt_Id = $_POST["alt_Id"];
//$id_member = $_POST["id_member"];
$emp_id = $_POST["emp_id"];
//it
$datetimeRstIt = $_POST["datetimeRstIt"];
$timeRstIt = $_POST["datetimeRstIt"];
$mydatetimeResIt =date('Y-m-d', strtotime($datetimeRstIt));
$mytimeResIt = date('H:i:s', strtotime($timeRstIt));
//
$datetimeRst = $_POST["datetimeRst"];
$timeRst = $_POST["datetimeRst"];
$mydatetimeRes=date('Y-m-d', strtotime($datetimeRst));
$mytimeRes = date('H:i:s', strtotime($timeRst));

$altStatus = $_POST["opStatus"];


  
if (empty($rst_id)) {
$sql = "INSERT INTO `db_itmanager`.`rstcomservice` (
`rst_notCan` ,
`rst_detail` ,
`id_member` ,
`rst_sentDate` ,
`rst_sentTime` ,
`emp_id` ,
`rst_inDate` ,
`rst_inTime` ,
`alt_Id` ,
`rst_create`
)
VALUES (
 '$radResult', '$rstDetail', '$id_member', '$mydatetimeResIt' , '$mytimeResIt' , '$emp_id', '$mydatetimeRes' , '$mytimeRes' , '$alt_Id', NOW( )
)";
mysql_query($sql);

$sqlalt = "UPDATE  `db_itmanager`.`altcomservice` 
        SET  `alt_status` =  '$altStatus' 
            WHERE  `altcomservice`.`alt_Id` = '$alt_Id'";
    mysql_query($sqlalt);
    
} else {
 $sqlUpdate = "UPDATE `db_itmanager`.`rstcomservice` SET 
`rst_notCan` = '$radResult',
`rst_detail` = '$rstDetail',
`id_member` = '$id_member',
`rst_sentDate` = '$mydatetimeResIt',
`rst_sentTime` = '$mytimeResIt' ,
`emp_id` = '$emp_id',
`rst_inDate` = '$mydatetimeRes' ,
`rst_inTime` = '$mytimeRes' ,
`alt_Id` = '$alt_Id'
WHERE `rstcomservice`.`rst_id` = '$rst_id' ";
 mysql_query($sqlUpdate);
}
if (mysql_query) {
  header("location:altServiceComUp.php?alt_Id=$alt_Id");
  //    header("location:listCom.php");
//    echo "<script language='javascript'>
//			   alert('Complete');
//			   setTimeout(\"parent.$.fancybox.close()\",1000); 
//			  </script>";
//    echo "<meta http-equiv='refresh' content='5; url=listCom.php'>";
} else {
    echo mysql_error();
}
?>
